﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Apprenda.SaaSGrid;

namespace SaaSKit.Taskr.Service
{
    public static class SettingsDTOExtension
    {
        public static Settings MapTo(this SettingsDTO dto)
        {
            return new Settings()
            {
                CustomStyle = dto.CustomStyle,
                CustomStatuses = dto.CustomStatuses,
                CustomLogoUrl = dto.CustomLogoUrl == null ? null : dto.CustomLogoUrl.ToString()
            };
        }

        public static void MapInto(this SettingsDTO dto, Settings instance)
        {
            instance.CustomStyle = dto.CustomStyle;
            instance.CustomStatuses = dto.CustomStatuses;
            instance.CustomLogoUrl = dto.CustomLogoUrl == null ? null : dto.CustomLogoUrl.ToString();
        }

        public static void MapFrom(this SettingsDTO dto, Settings instance)
        {
            if (instance == null)
            {
                return;
            }

            dto.CustomStyle = instance.CustomStyle;
            dto.CustomStatuses = instance.CustomStatuses;
            dto.CustomLogoUrl = instance.CustomLogoUrl == null ? null : new Uri(instance.CustomLogoUrl);
        }
    }
}
